//
//  WorkHomeVC.m
//  XLDoctor
//
//  Created by longma on 2018/7/27.
//  Copyright © 2018年 XLH. All rights reserved.
//

#import "MJLabelController.h"
#import "StrokeLabel.h"
@interface MJLabelController ()
@property (weak, nonatomic) IBOutlet StrokeLabel *strokeLabel1;
@property (weak, nonatomic) IBOutlet StrokeLabel *strokeLabel2;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *strokeLabel1W;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *strokeLabel2W;
//
@property (weak, nonatomic) IBOutlet UILabel *disclaimerLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *disclaimerBgViewH;
//
@property (weak, nonatomic) IBOutlet EdgeInsetsLabel *edgeInsetsLabel;
//
@property (weak, nonatomic) IBOutlet UILabel *aiLabel;
@property (weak, nonatomic) IBOutlet UILabel *aichenterLabel;
//
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;

@end

@implementation MJLabelController


- (void)viewDidLoad {
    [super viewDidLoad];
   
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
}

- (void)mj_setUI{
    [super mj_setUI];
    
    self.title = @"MJLabelController";
    
    //文本抖动
    [self initTriangleLabel];
    //TTTAttributedLabel 下划线点击跳转
    [self initTTTAttributedLabel];
    //计算文本行数
    [self initNumberLineLabel];
    //富文本指定文本对齐方式
    [self initVerticalCenterLabel];
    //文本内边距
    [self initEdgeInsetsLabel];
    //字体描边 label
    [self initStrokeLabel];
    //计算文本高度宽度
    [self initHeightWidthLabel];
    
}
- (void)updateUI {
    UILabel *titleLabel = [[UILabel alloc]init];
    //字体的设置
    titleLabel.font = [UIFont fontWithName:@"Zapfino" size:20];
    //UILable“中文”加上“英文或者其他非中文字符”自动换行的问题，结尾自动换行问题
    titleLabel.lineBreakMode = NSLineBreakByWordWrapping; //英文换行
    titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; //结尾...
    //文字大小自适应标签宽度
    titleLabel.adjustsFontSizeToFitWidth = YES;//当文字超出标签宽度时，自动调整文字大小，使其不被截断

}
#pragma mark - 方法
#pragma mark - 文本抖动
- (void)initTriangleLabel {
//    TriangleLabView
}

#pragma mark - TTTAttributedLabel 下划线点击跳转
- (void)initTTTAttributedLabel {
//    setLinkAttributesWithTTTAttributedLabel
}

#pragma mark - 计算文本行数
- (void)initNumberLineLabel {
    self.numberLabel.text = @"计算行数-为了保障你的权益，继先";
    CGSize messageSize = [self.numberLabel sizeThatFits:CGSizeMake(SCREEN_WIDTH - 100*2, MAXFLOAT)];
    CGFloat messageHeight = messageSize.height;
    CGFloat messageLineHeight = self.numberLabel.font.lineHeight;
    NSInteger messageline = ceil(messageHeight)/messageLineHeight;
    if(messageline > 1){
        self.numberLabel.textAlignment = NSTextAlignmentLeft;
    }
}

#pragma mark - 文本内边距
- (void)initVerticalCenterLabel {
    //富文本,不同文字大小水平轴对齐问题(默认底部对齐)
//    self.aiLabel.text = @"开启居中文字复管理服务";
    self.aiLabel.font = MJUIFontBoldMake(20);
    [self.aiLabel mj_paragraphStyleWithArrString:@[@"指定文本"] font:[UIFont systemFontOfSize:11] color:UIColor.mj_appColor lineSpacing:0];
    //
    
    //富文本,不同文字大小水平轴对齐问题(中部对齐)
//    self.aichenterLabel.text = @"开启居中文字复管理服务";
    self.aichenterLabel.font = MJUIFontBoldMake(20);
    self.aichenterLabel.backgroundColor = UIColor.mj_redColor;
    [self.aichenterLabel mj_paragraphStyleWithArrString:@[@"指定文本"] font:[UIFont systemFontOfSize:11] color:UIColor.mj_appColor lineSpacing:0 verticalCenter:true];
}

#pragma mark - 文本内边距
- (void)initEdgeInsetsLabel {
    self.edgeInsetsLabel.backgroundColor = UIColor.redColor;
    self.edgeInsetsLabel.edgeInsets = UIEdgeInsetsMake(8, 8, 8, 8);
}

#pragma mark - 计算文本高度宽度
- (void)initHeightWidthLabel {
    NSString *text = @"为了保障你的权益，继续检测之前请先仔细阅读以下关于检测的免责声明：\n\n「乐尔健康」所展示的数据均来源于多参数分析仪的检测结果，并不独立提供检测服务或功能。\n\n「乐尔健康」中所有的检测结果，仅作为辅助参考使用，不可直接用于诊断和治疗，最终的诊疗决定须以医生的诊断结论或意见为准。如果违反使用原则造成任何健康风险和法律后果均与「乐尔健康」无关。";
    self.disclaimerLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:14];
    self.disclaimerLabel.text = text;
    self.disclaimerLabel.numberOfLines = 0;
    [self.disclaimerLabel mj_paragraphStyleWithLineSpacing:5];
    CGSize size222 = [self.disclaimerLabel sizeThatFits:CGSizeMake(SCREEN_WIDTH - 60, MAXFLOAT)];
    NSLog(@"size222 ===== %@", NSStringFromCGSize(size222));
    self.disclaimerBgViewH.constant = size222.height;
}

#pragma mark - 字体描边 label
- (void)initStrokeLabel {
    UIFont *font = [UIFont fontWithName:@
    "AvenirNextCondensed-Bold"
    size:30];
    UIColor *color = MJUIColorFromHex(0x686868);
    
    self.strokeLabel1.font = font;
    self.strokeLabel1.textColor = color;
    self.strokeLabel1.strokeColor = [UIColor whiteColor];
    self.strokeLabel1.strokeWidth = 6;
    
    self.strokeLabel2.font = font;
    self.strokeLabel2.textColor = color;
    self.strokeLabel2.strokeColor = [UIColor whiteColor];
    self.strokeLabel2.strokeWidth = 6;

    CGSize strokeLabel1Size = [self.strokeLabel1 sizeThatFits:CGSizeMake(MAXFLOAT, 40)];
    self.strokeLabel1W.constant = strokeLabel1Size.width + 10;
    
    CGSize strokeLabel2Size = [self.strokeLabel2 sizeThatFits:CGSizeMake(MAXFLOAT, 40)];
    self.strokeLabel2W.constant = strokeLabel2Size.width + 10;
    
    NSArray*familyNames = [UIFont familyNames];
    for(NSString*familyName in familyNames )
    {
        printf("Family: %s \n", [familyName UTF8String]);
        NSArray*fontNames = [UIFont fontNamesForFamilyName:familyName];
        for(NSString*fontName in fontNames )
        {
            printf("\tFont: %s \n", [fontName UTF8String] );
        }
    }
}

#pragma mark - 代理

#pragma mark - 懒加载

@end
